package cn.czxy.dao.zy.user;

import cn.czxy.domain.User;
import cn.itcast.xml.XmlUtils;

import java.util.List;

/**
 * @author zhangyuan@163.com
 * @date 2019/4/12
 * @infos
 */
public class UserDao {

    private static String File_path ;

    static {
        File_path= UserDao.class.getClassLoader().getResource("Users.xml").getPath();
    }


    public void addUser(User user) {
        XmlUtils.write(File_path,user,true);
    }

    /**
     * 查询所有的用户
     * @return
     */
    public List<User> readAll()
    {
        System.out.println(File_path);
        List<User> list = XmlUtils.readAll(File_path, User.class);

        return list;
    }


}
